﻿using System;
using System.Collections.Generic;

namespace ObjectPool.Test
{
    public class IManagedImpl : IManaged, IManagedEvent
    {
        private int size = 10;
        private List<string> data = new List<string>();

        public int InvokeInitCount { get; private set; }

        public int InvokeOnStoreCount { get; private set; }

        public int InvokeOnExtractCount { get; private set; }

        public int InvokeOnRestoreCount { get; private set; }

        public int InvokeOnReleaseCount { get; private set; }

        public List<string> GetData()
        {
            return data;
        }

        public int GetExpectSize()
        {
            return size;
        }

        public void Clear()
        {
            data.Clear();
        }

        public void Init()
        {
            for (int i=0; i<size; i++)
            {
                data.Add(Guid.NewGuid().ToString("N"));
            }
            InvokeInitCount++;
        }

        public void OnStore()
        {
            InvokeOnStoreCount++;
        }

        public void OnExtract()
        {
            InvokeOnExtractCount++;
        }

        public void OnRestore()
        {
            InvokeOnRestoreCount++;
        }

        public void OnRelease()
        {
            InvokeOnReleaseCount++;
        }
    }
}
